/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package minesweeper;

import javax.swing.ButtonGroup;

/**
 *
 * @author Gustavo
 */
public class Config extends java.awt.Dialog {

    /**
     * Creates new form Config
     */
    private MazeView parent;
    public Config(MazeView parent) {
        super(parent, true);
        initComponents();
        this.parent=parent;
        ButtonGroup bg = new ButtonGroup();
        bg.add(rbEasy);
        bg.add(rbEasy1);
        bg.add(rbMedium);
        bg.add(rbHard);
        Easy.setText("10x10 10 Bombs: ");
        Easy1.setText("20x20 20 Bombs: ");
        Medium.setText("20x20 40 Bombs: ");
        Hard.setText("20x20 99 Bombs: ");
        rbEasy.setText("");
        rbEasy1.setText("");
        rbMedium.setText("");
        rbHard.setText("");
        ok.setText("OK");
        cancel.setText("Cancel");
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        Easy = new javax.swing.JLabel();
        rbEasy = new javax.swing.JRadioButton();
        rbMedium = new javax.swing.JRadioButton();
        rbHard = new javax.swing.JRadioButton();
        Medium = new javax.swing.JLabel();
        Hard = new javax.swing.JLabel();
        ok = new javax.swing.JButton();
        cancel = new javax.swing.JButton();
        Easy1 = new javax.swing.JLabel();
        rbEasy1 = new javax.swing.JRadioButton();

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Choose Difficulty", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(0, 0, 0)));

        Easy.setText("jLabel3");

        rbEasy.setText("jRadioButton1");
        rbEasy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbEasyActionPerformed(evt);
            }
        });

        rbMedium.setText("jRadioButton2");

        rbHard.setText("jRadioButton2");

        Medium.setText("jLabel3");

        Hard.setText("jLabel3");

        ok.setText("jButton1");
        ok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okActionPerformed(evt);
            }
        });

        cancel.setText("jButton1");
        cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelActionPerformed(evt);
            }
        });

        Easy1.setText("jLabel3");

        rbEasy1.setText("jRadioButton1");
        rbEasy1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbEasy1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(ok)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cancel))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Easy)
                            .addComponent(Medium)
                            .addComponent(Hard))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rbEasy)
                            .addComponent(rbMedium)
                            .addComponent(rbHard)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(Easy1)
                        .addGap(18, 18, 18)
                        .addComponent(rbEasy1)))
                .addContainerGap(35, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Easy)
                    .addComponent(rbEasy))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Easy1)
                    .addComponent(rbEasy1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Medium)
                    .addComponent(rbMedium))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Hard)
                    .addComponent(rbHard))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ok)
                    .addComponent(cancel))
                .addContainerGap(13, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Closes the dialog
     */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        setVisible(false);
        dispose();
    }//GEN-LAST:event_closeDialog
    
    private void rbEasyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbEasyActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_rbEasyActionPerformed
    
    private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
        this.setVisible(false);
        dispose();
    }//GEN-LAST:event_cancelActionPerformed

    private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
        if(rbEasy.isSelected()){
            try{
            Maze maze = new Maze(10, 10, 10);
            parent.setMaze(maze);
            }
            catch(Exception e)
            {
                System.out.println("INVALID MAZE 10x10x10");
            }
        }
        if(rbEasy1.isSelected()){
            try{
            Maze maze = new Maze(20, 20, 20);
            parent.setMaze(maze);
            }
            catch(Exception e)
            {
                System.out.println("INVALID MAZE 20x20x20");
            }
        }
            if(rbMedium.isSelected()){
                try{
            Maze maze = new Maze(20, 20, 40);
            parent.setMaze(maze);
            }
            catch(Exception e)
            {
                System.out.println("INVALID MAZE 20x20x40");
            }
            }
            
        if(rbHard.isSelected()){
            try{
            Maze maze = new Maze(20, 20, 99);
            parent.setMaze(maze);
            }
            catch(Exception e)
            {
                e.printStackTrace();
                System.out.println("INVALID MAZE 20x20x99");
            }
        }
            
        this.setVisible(false);
        dispose();        
    }//GEN-LAST:event_okActionPerformed

    private void rbEasy1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_rbEasy1ActionPerformed
    {//GEN-HEADEREND:event_rbEasy1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_rbEasy1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Easy;
    private javax.swing.JLabel Easy1;
    private javax.swing.JLabel Hard;
    private javax.swing.JLabel Medium;
    private javax.swing.JButton cancel;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JButton ok;
    private javax.swing.JRadioButton rbEasy;
    private javax.swing.JRadioButton rbEasy1;
    private javax.swing.JRadioButton rbHard;
    private javax.swing.JRadioButton rbMedium;
    // End of variables declaration//GEN-END:variables
}
